import React,{Component} from 'react';
import {
    Table,Button, Col, Row, Input, Select, message,Pagination,Card,Tabs,Form,Switch,DatePicker,Popconfirm
} from 'antd';
import { $http } from '../../containers/config/https';
import store from '../../store';
import moment from 'moment';
import CBDataImport from './CBDataImport';
import CommonPagination from 'components/pagination/index';

const Option=Select.Option
const TabPane = Tabs.TabPane;
const FormItem = Form.Item;
const formItemLayout = {
    labelCol: { span: 7 },
    wrapperCol: { span: 16 },
}
const formItemNewButton = {
    labelCol: { span: 6 },
    wrapperCol: { span: 16 },
}
const formItemLayoutNumber = {
    labelCol: { span: 9 },
    wrapperCol: { span: 14 },
}

const HospitalMaintenance = Form.create()(
class HospitalMaintenance extends Component { 
    constructor(props) {
        super(props);
        this.state = {
            data:[],
            columns:[],
            rowId:"",
            total: 0,
            page: 1,
            pageSize: 10,
            baseParms:[],
            values:{},
            hospID:"",
            higherHospID:"",
            healthBureauArr:[],//卫生局
            superiorHospitalArr:[],//上级医院
            cityArr:[],
            areasArr: [],
            VillagesArr:[],
            hamletsArr: [],
            heightTable:""
        }
    }
    componentDidMount() {
        // 初始化设置table的高度以及表体的高度 内容高度 height 
        if(document.querySelector('.ant-table-body')){
            document.querySelector('.ant-table-body').style.height = store.getState().tableHeight.y - 40 + 'px'
        }
        this.FindData()
        this.getHealthBureauArr()
        this.getBaseParams()
      }
      //获取对应的医院基础信息数据
      getBaseParams=()=>{
        let data = {
            params: [ {
                
            }],
        }
        $http.post("urlS",this, {
            code: "05100224",
            data: data,
            success: function (res) { 
                if (+res.errorCode === 0) {
                   this.setState({
                    baseParms:res.result
                    })
                } else {
                    message.error('失败：' + res.errorMessage);
                }
            },
            error:function (error) {
                message.error('失败：' + error);
            }
        })   
      }
      //获取卫生局下拉框数据
      getHealthBureauArr=()=>{
        let data = {
            params: [ {
            }],
        }
        $http.post("urlS",this, {
            code: "05100220",
            data: data,
            success: function (res) { 
                if (+res.errorCode === 0) {
                   this.setState({
                      healthBureauArr:res.result.Data
                    })
                } else {
                    message.error('失败：' + res.errorMessage);
                }
            },
            error:function (error) {
                message.error('失败：' + error);
            }
        })   
      }
    setRowClassName = (record) => {
        return record.hospID === this.state.rowId ? 'clickRowStyle' : '';
    }

    handleFind=()=>{
                this.setState({ page: 1, pageSize: 10 ,}, () => {
                    this.FindData()
                  })
    }
    FindData=(rowId,record)=>{
        let {pageSize,page} = this.state;
        let data = {
            params: [ {
                hospCode:this.props.form.getFieldValue('codeSearch')&&this.props.form.getFieldValue('codeSearch')?this.props.form.getFieldValue('codeSearch'):"",
                hospDesc:this.props.form.getFieldValue('decSearch')&&this.props.form.getFieldValue('decSearch')?this.props.form.getFieldValue('decSearch'):"",
                hospStatus:this.props.form.getFieldValue('statusSearch')&&this.props.form.getFieldValue('statusSearch')?this.props.form.getFieldValue('statusSearch'):"",
            }],
            pagination:[{
              pageSize: pageSize,
              currentPage: page,
            }]
        }
        $http.post("urlS",this, {
            code: "05100219",
            data: data,
            success: function (res) { 
                if (+res.errorCode === 0) {
                   this.setState({
                       data:res.result.Data,
                       total: res.result.TotalCount,
                       rowId:rowId&&rowId?rowId:"",
                       hospID:rowId&&rowId?rowId:"",
                       higherHospID:record&&record?record.higherHospID:"",
                       params:record&&record?record:"",
                    },()=>{
                        // this.getBaseParams()
                    })
                } else {
                    message.error('失败：' + res.errorMessage);
                }
            },
            error:function (error) {
                message.error('失败：' + error);
            }
        })     
    }
    // 页码改变的回调，参数是改变后的页码及每页条数
    PageChange = (page, pageSize)=> {
        this.setState({page: page, pageSize: pageSize}, () => {
          // 重新调用查询方法
            this.FindData()
        });
    }
    // 条数改变的回调
    onShowSizeChange = (current, size) => {
        this.setState({page: current, pageSize: size}, () => {
            // 重新调用查询方法
            this.FindData()
        });
    }
    onClickRow = (record) => {
        //给右边的编辑form传值
        return {
            onClick: () => {
                // console.log("record",record)
                this.reset()
                    this.setState({
                        params:record,
                        hospID:record.hospID,
                        higherHospID:record.higherHospID,
                        cityArr:[],
                        areasArr:[],
                        VillagesArr:[],
                    })
                if(this.state.rowId===""){
                    this.setState({
                        rowId: record.hospID,
                    });
                }else{
                    if(this.state.rowId!==record.hospID){
                        this.setState({
                            rowId: record.hospID,
                        });
                    }else{
                        this.setState({
                            rowId: "",
                        });
                        this.reset()
                        this.setState({
                            params:{},
                            hospID:"",
                            higherHospID:"",
                            cityArr:[],
                            areasArr:[],
                            VillagesArr:[],
                        })
                    }
                }
            },
        };
    }
    ImportData=()=>{
        this.DataImport.DrawerShow()
    }
    handleSwithChange=(val)=>{
    }
    handleStatus=(v)=>{
    }
    save=()=>{
        this.props.form.validateFields((err, values) => {
            const {page,pageSize} = this.state
            if(!err){
                let data = {
                    params: [ {
                        hospID:this.state.rowId&&this.state.rowId?this.state.hospID:"",
                        hospSeqNo:values.hospSeqNo || "",
                        hospCode:values.hospCode || "",
                        hospDesc:values.hospDesc || "",
                        healBureauID:values.healBureauID || "",
                        higherHospID:this.state.higherHospID || "",
                        hospGradeID:values.hospGradeID || "",
                        hospTypeID:values.hospTypeID || "",
                        hospNatureID:values.hospNatureID || "",
                        address:values.address || "",
                        deanName:values.deanName || "",
                        officePhone:values.officePhone || "",
                        email:values.email || "",
                        provID:values.provID || "",
                        cityID:values.cityID || "",
                        areaID:values.areaID || "",
                        villageID:values.villageID || "",
                        clinicFlag:values.clinicFlag==true?"Y":"N",
                        organizationCode:values.organizationCode || "",
                        businesslicense:values.businesslicense || "",
                        ZIPCode:values.ZIPCode || "",
                        website:values.website || "",
                        startDate:values.startDate ? moment(values.startDate).format('YYYY-MM-DD') : undefined,
                        stopDate:values.stopDate ? moment(values.stopDate).format('YYYY-MM-DD') : undefined,
                        updateUserID:sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                        authorizeCode:values.authorizeCode || "",
                        introduce:values.introduce || "",
                        logo:values.logo || "",
                        oneRowNumber:values.oneRowNumber || "",
                        height:values.height || "",
                        width:values.width || "",
                        bedInterval:values.bedInterval || "",
                    }],
                    pagination:[{
                      pageSize: pageSize,
                      currentPage: page,
                    }]
                }
                $http.post("urlS",this, {
                    code: "05100209",
                    data: data,
                    success: function (res) { 
                        if (+res.errorCode === 0) {
                         if(this.state.rowId&&this.state.rowId){
                            message.success("修改成功")
                            this.setState({
                              rowId:this.state.hospID,
                            })
                            this.FindData(this.state.rowId,this.state.params)
                         }else{
                            message.success("新增成功")
                            this.reset()
                            this.setState({
                            rowId:"",
                            })
                            this.FindData()
                         }
                        } else {
                            message.error('失败：' + res.errorMessage);
                        }
                    },
                    error:function (error) {
                        message.error('失败：' + error);
                    }
                }) 
            }else{
            }
        })
    }
    delete=()=>{
        let data = {
            params: [ {
                hospID:this.state.hospID,
                updateUserID:sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
            }],
        }
        $http.post("urlS",this, {
            code: "05100210",
            data: data,
            success: function (res) { 
                if (+res.errorCode === 0) {
                 message.success("删除成功")
                 this.reset()
                 this.FindData()
                } else {
                    message.error('失败：' + res.errorMessage);
                }
            },
            error:function (error) {
                message.error('失败：' + error);
            }
        }) 
    }
    reset=()=>{
        this.setState({
            params:{}
        })
        this.props.form.resetFields();
    }
    //省拼检索上级医院
    handleSearch=(val)=>{
        let data = {
            params: [{
                higherHospDesc: val,
            }]
        };
        //上级医院下拉
        if(val){
            $http.post('urlS', this, {
                code: "05100223",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({superiorHospitalArr: res.result.Data})
                    }
                }
            })
        }
    }
    //上级医院点击获取id
    handleSuperior=(v)=>{
        this.setState({
            higherHospID:v.key
        })
    }
    //清空上级医院
    handleClear=(v)=>{
        if(!v){
            this.setState({
                higherHospID:""
            })
        }
    }
    //选择清除省
    handleProvince=(flag,value,option)=>{
        if (value) {
            let city = []
            city = this.state.baseParms.provDataList.filter((item) => item.id == value);
            this.setState({
                cityArr:city[0].cityDataList,
                areasArr:[],
                VillagesArr:[]
            })
            this.props.form.setFieldsValue({ cityID:undefined, areaID: undefined,villageID:undefined })
        }else{
            this.props.form.setFieldsValue({ cityID:undefined, areaID: undefined,villageID:undefined })  
            this.setState({
                cityArr:[],
                areasArr:[],
                VillagesArr:[]
            })
        }
    }
    //选择市
    handleCity=(flag,value)=>{
        if(value){
            this.getAreas(value)
        }else{
            this.props.form.setFieldsValue({  areaID: undefined,villageID:undefined })  
            this.setState({
                areasArr:[],
                VillagesArr:[]
            })
        }
    }
    //市获取焦点
    onCityFocus = () => {
        let city = this.state.cityArr;
        let provinceID = this.props.form.getFieldValue("provID");
        if ((city.length === 0) && (provinceID)) {
            let newCity = []
            newCity = this.state.baseParms.provDataList.filter((item) => item.id == provinceID);
            this.setState({
                cityArr:newCity[0].cityDataList,
            })
        }
    }
    //县获取焦点
    onAreasFocus = () => {
        let area = this.state.areasArr
            let cityID = this.props.form.getFieldValue("cityID");
            if ((area.length === 0) && (cityID)) {
                this.getAreas(cityID);
            }
    }
    //乡获取焦点
    onVillagesFocus = () => {
        let village = this.state.VillagesArr
            let areaID = this.props.form.getFieldValue("areaID");
            if ((village.length === 0) && (areaID)) {
                this.getVillages(areaID);
            }
    }
    //选择县
    handleAreas=(flag,value)=>{
        if(value){
            this.getVillages(value)
        }else{
            this.props.form.setFieldsValue({villageID:undefined })  
            this.setState({
                VillagesArr:[]
            })
        }
    }
    //选择市 加载县
    getAreas = (cityID) => {
        let data = {
            params: [{
                cityId: cityID
            }],
        }
        $http.post('urlS', this, {
            code: '03030006',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                        this.setState({
                            areasArr: res.result,
                        })
                } else {
                    this.setState({
                        areasArr: [],
                        VillagesArr:[],
                        hamletsArr: [],
                    })
                }
            }
        })
    }
     //选择县时加载乡数据
     getVillages = (countyID) => {
        let data = {
            params: [{
                areaId: countyID,
            }],
        }
        $http.post('urlS', this, {
            code: '03030007',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    this.setState({
                        VillagesArr:res.result,
                    })
                } else {
                    this.setState({
                        VillagesArr:[],
                        hamletsArr: [],
                    })
                }
            }
        })
    }
    // 显示分页总条数
    showTotal(total) {
        return `共 ${total} 条`;
      }
    render() {
        const { getFieldDecorator } = this.props.form;
        const {baseParms,params,healthBureauArr,superiorHospitalArr,cityArr,areasArr,
            VillagesArr, hamletsArr, } = this.state
        const columns = [{
            key: '1',
            title: '代码',
            dataIndex: 'hospCode',
            width: '15%',
            align: "center",
          }, {
            key: '2',
            title: '描述',
            dataIndex: 'hospDesc',
            width: '15%',
            align: 'center'
          },]
          const statusArr = [
            {
                id: '',
                descripts: '全部',
                descriptsSPCode: 'QB',
              }, {
            id: '1',
            descripts: '可用',
            descriptsSPCode: 'KY',
          },{
            id: '0',
            descripts: '不可用',
            descriptsSPCode: 'BKY',
          },]

          let statusoP = []
          statusArr && statusArr.map(item => {
            statusoP.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}  value={String(item.id)}>{item.descripts}</Option>)
          })
        //卫生局
        let healthBureauoP = []
        healthBureauArr && healthBureauArr.map(item => {
            healthBureauoP.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        })
        //上级医院
        let superiorHospitalOp = []
        superiorHospitalArr && superiorHospitalArr.map(item => {
            superiorHospitalOp.push(<Option key={item.hospID} onClick={this.handleSuperior}  role={item.hospDesc} title={item.hospDesc} value={String(item.hospID)}>{item.hospDesc}</Option>)
        })  
        //医院级别
        let hospitalLevelOp = []
        baseParms.hospGradeList && baseParms.hospGradeList.map(item => {
            hospitalLevelOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        }) 
        //医院类型
        let hospitalTypeOp = []
        baseParms.hospTypeList && baseParms.hospTypeList.map(item => {
            hospitalTypeOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        }) 
        //医院性质
        let hospitaNatureOp = []
        baseParms.hospNatureList && baseParms.hospNatureList.map(item => {
            hospitaNatureOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        }) 
        //省
        let provinceOp = []
        baseParms.provDataList && baseParms.provDataList.map(item => {
            provinceOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        }) 
        //市
        let cityOp = []
        cityArr && cityArr.map(item => {
            cityOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        })
        if ((cityArr) && (cityArr.length === 0) &&params&& (params.cityID)) {
            cityOp.push(<Option key={params.cityID} role={params.cityDesc} title={params.cityDesc} value={String(params.cityID)}>{params.cityDesc}</Option>)
        } 
        //县
        let areaOp = []
        areasArr && areasArr.map(item => {
            areaOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        })  
        if ((areasArr) && (areasArr.length === 0) &&params&& (params.areaID)) {
            areaOp.push(<Option key={params.areaID} role={params.areaDesc} title={params.areaDesc} value={String(params.areaID)}>{params.areaDesc}</Option>)
        } 
        //乡
        let villagesOp = []
        VillagesArr && VillagesArr.map(item => {
            villagesOp.push(<Option key={item.id}  role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
        }) 
        if ((VillagesArr) && (VillagesArr.length === 0) &&params&& (params.villageID)) {
            villagesOp.push(<Option key={params.villageID} role={params.villageDesc} title={params.villageDesc} value={String(params.villageID)}>{params.villageDesc}</Option>)
        } 
        /*const formItemLayout = {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 8 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 },
            },
        };
        const tailFormItemLayout = {
            wrapperCol: {
                xs: {
                span: 24,
                offset: 0,
                },
                sm: {
                span: 16,
                offset: 8,
                },
            },
        };*/
        return (
            <div>
                <Row gutter={60} style={{margin:"0"}}>
                    <Col span={24}>
                        <div>
                            <Card >
                                <Form>
                            <Row gutter={60}>
                                <Col span={4} >
                                <FormItem {...formItemLayout} label='描述'>
                                        {getFieldDecorator('decSearch', {
                                            rules: [{ required: false, message: '' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={4} >
                                <FormItem {...formItemLayout} label='代码'>
                                        {getFieldDecorator('codeSearch', {
                                            rules: [{ required: false, message: '' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={4} >
                                    <FormItem {...formItemLayout} label='状态'>
                                        {getFieldDecorator('statusSearch', {
                                            initialValue: "",
                                            rules: [{ required:false, message: '' }],
                                        })(
                                            <Select
                                            style={{ width: '70%' }}
                                            onSelect={this.handleStatus}
                                            >
                                              {statusoP}  
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={2}>
                                    <Button type="primary" onClick={this.handleFind}>查询</Button> 
                                </Col>
                                    <Col span={2}>
                                        <Button type="primary" onClick={this.ImportData}>数据导入</Button>
                                        <input  type='file' accept='.xlsx, .xls' style={{display:'none'}} onChange={this.onImportExcel} onClick={this.handleClick} ref={el => this.fileInput = el} />
                                </Col>
                            </Row>
                            </Form>   
                            </Card>
                        </div>
                    </Col>
                    </Row>
                <Row gutter={60} style={{margin:"0"}}>
                    <Col span={8}>
                    <Card >
                    <div>
                        <Table
                            dataSource={this.state.data}
                            columns={columns}
                            rowClassName={this.setRowClassName}
                            pagination={false}
                            bordered
                            onRow={this.onClickRow}
                            rowKey="ID"
                            // style={{height: store.getState().tableHeight.y + 34 + 'px'}}
                            style={{height: store.getState().tableHeight.y + 20 + 'px'}}
                            scroll={{ x: 200, y: store.getState().tableHeight.y-40 }} //max-height 内容高度
                           
                        />
                        {/* 分页: total--总条数  defaultCurrent--默认的当前页 hideOnSinglePage--只有一页时隐藏分页器 */}
                        {/* <CommonPagination size={this.state.size} current={this.state.page} total={this.state.total} search={this.state.search}
                                        onShowSizeChange={this.onShowSizeChange.bind(this)} complete={true} dataSource={this.state.leftData}
                                        onChange={this.PageChange.bind(this)} /> */}
                        <Pagination
                            size="small"
                            showQuickJumper
                            showSizeChanger
                            defaultCurrent={1}
                            current={this.state.page}
                            total={this.state.total}
                            onChange={this.PageChange}
                            onRow={this.selectID}
                            onShowSizeChange={this.onShowSizeChange}
                            style={{textAlign: "right", marginTop: '10px'}}
                            showTotal={() => this.showTotal(this.state.total)}
                        />,
                    </div>
                    </Card>
                    </Col>
                    <Col span={16} style={{paddingLeft:"0px"}}>
                        <div>
                            <Card>
                                <Form style={{ height: "100%", overflow: "hidden auto" }}>
                                <Row gutter={60}>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='序号'>
                                            {getFieldDecorator('hospSeqNo', {
                                                initialValue: params&&params.hospSeqNo ?  params&&params.hospSeqNo : undefined,
                                                rules: [{ required: false, message: '请输入', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='代码'>
                                        {getFieldDecorator('hospCode', {
                                            initialValue: params&&params.hospCode ?  params.hospCode : undefined,
                                            rules: [{ required: true, message: '请输入代码' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='描述'>
                                        {getFieldDecorator('hospDesc', {
                                            initialValue: params&&params.hospDesc ?  params&&params.hospDesc : undefined,
                                            rules: [{ required: true, message: '请输入描述' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='卫生局'>
                                        {getFieldDecorator('healBureauID', {
                                           initialValue: params&&params.healBureauID ?   String(params.healBureauID): undefined,
                                            rules: [{ required:true, message: '请选择卫生局' }],
                                        })(
                                            <Select showSearch allowClear optionFilterProp="role" >
                                                {healthBureauoP}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row gutter={60}>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='上级医院'>
                                            {getFieldDecorator('higherHospID', {
                                                initialValue: params&&params.higherHospDesc ? String(params.higherHospDesc) : undefined,
                                                rules: [{ required: false, message: '请选择上级医院', },
                                                ],
                                            })(
                                                <Select placeholder="请输入首拼进行检索" onChange={this.handleClear} showSearch allowClear onSearch={this.handleSearch} showArrow={false} filterOption={false} defaultActiveFirstOption={false} notFoundContent={null}  optionFilterProp="role" >
                                                {superiorHospitalOp}
                                            </Select>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='医院级别'>
                                        {getFieldDecorator('hospGradeID', {
                                            initialValue: params&&params.hospGradeID ?   String(params.hospGradeID) : undefined,
                                            rules: [{ required:true, message: '请选择医院级别' }],
                                        })(
                                            <Select showSearch allowClear optionFilterProp="role" >
                                                {hospitalLevelOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='医院类型'>
                                        {getFieldDecorator('hospTypeID', {
                                            initialValue: params&&params.hospTypeID ?  String(params.hospTypeID): undefined,
                                            rules: [{ required:true, message: '请选择医院类型' }],
                                        })(
                                            <Select showSearch allowClear optionFilterProp="role" >
                                                {hospitalTypeOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='医院性质'>
                                        {getFieldDecorator('hospNatureID', {
                                           initialValue: params&&params.hospNatureID ?   String(params.hospNatureID) : undefined,
                                            rules: [{ required:true, message: '请选择医院性质' }],
                                        })(
                                            <Select showSearch allowClear optionFilterProp="role" >
                                                {hospitaNatureOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row gutter={60}>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='物理位置'>
                                            {getFieldDecorator('address', {
                                               initialValue: params&&params.address ?  params.address : undefined,
                                                rules: [{ required: true, message: '', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='院长'>
                                        {getFieldDecorator('deanName', {
                                          initialValue: params&&params.deanName ?  params&&params.deanName : undefined,
                                            rules: [{ required: false, message: '' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='院长电话'>
                                        {getFieldDecorator('deanPhone', {
                                           initialValue: params&&params.deanPhone ?  params&&params.deanPhone: undefined,
                                            rules: [{ required: false, message: '' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='院办电话'>
                                        {getFieldDecorator('officePhone', {
                                           initialValue: params&&params.officePhone ?  params&&params.officePhone : undefined,
                                            rules: [{ required: false, message: '' }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row gutter={60}>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='医院邮箱'>
                                            {getFieldDecorator('email', {
                                               initialValue: params&&params.email ?  params&&params.email : undefined,
                                                rules: [{ required: false, message: '请输入', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='省'>
                                        {getFieldDecorator('provID', {
                                          initialValue: params&&params.provID ?  String(params.provID) : undefined,
                                            rules: [{ required:true, message: '请选择省' }],
                                        })(
                                            <Select onChange={this.handleProvince.bind(this,"prov")}  showSearch allowClear optionFilterProp="role" >
                                                {provinceOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='市'>
                                        {getFieldDecorator('cityID', {
                                           initialValue: params&&params.cityID ?  String(params.cityID) : undefined,
                                            rules: [{ required:true, message: '请选择市' }],
                                        })(
                                            <Select  onFocus={this.onCityFocus.bind(this,)} onChange={this.handleCity.bind(this,"city")} showSearch allowClear optionFilterProp="role" >
                                                {cityOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='县'>
                                        {getFieldDecorator('areaID', {
                                           initialValue: params&&params.areaID ?  String(params.areaID): undefined,
                                            rules: [{ required:true, message: '请选择县' }],
                                        })(
                                            <Select onFocus={this.onAreasFocus.bind(this,)} onChange={this.handleAreas.bind(this,"area")}   showSearch allowClear optionFilterProp="role" >
                                                {areaOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row gutter={60}>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='乡'>
                                        {getFieldDecorator('villageID', {
                                            initialValue: params&&params.villageID ?  String(params.villageID) : undefined,
                                            rules: [{ required:false, message: '请选择乡' }],
                                        })(
                                            <Select onFocus={this.onVillagesFocus.bind(this,)} showSearch allowClear optionFilterProp="role" >
                                                {villagesOp}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                    <FormItem {...formItemLayout} label='诊所'>
                                        {getFieldDecorator('clinicFlag', {
                                           initialValue: params&&params.clinicFlag ?  params&&params.clinicFlag : undefined,
                                            rules: [{ required:false, message: '请选择' }],
                                        })(
                                            // checked={record.logLocIsDefault&&record.logLocIsDefault=="Y"?true:false}
                                            <Switch checkedChildren="是" unCheckedChildren="否" onChange={(val)=>this.handleSwithChange(val,)}  />
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='机构代码'>
                                            {getFieldDecorator('organizationCode', {
                                             initialValue: params&&params.organizationCode ?  params&&params.organizationCode : undefined,
                                                rules: [{ required: true, message: '请输入机构代码', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='营业执照'>
                                            {getFieldDecorator('businesslicense', {
                                               initialValue: params&&params.businesslicense ?  params&&params.businesslicense : undefined,
                                                rules: [{ required: true, message: '请输入', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='邮编'>
                                            {getFieldDecorator('ZIPCode', {
                                                validateTrigger: ["onPressEnter", "onBlur"],
                                               initialValue: params&&params.ZIPCode ?  params&&params.ZIPCode : undefined,
                                                rules: [{ required: true, message: '请输入邮编', },
                                                { pattern: new RegExp(/^[0-9][0-9]{5}$/), message: '请输入正确的邮编' }],
                                                getValueFromEvent: (event) => {
                                                    return event.target.value.replace(/\D/g, '')
                                                }
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='网站'>
                                            {getFieldDecorator('website', {
                                                initialValue: params&&params.website ?  params&&params.website : undefined,
                                                rules: [{ required: true, message: '请输入网站', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6} className="starDataDom">
                                    <FormItem label='生效日期' {...formItemLayout}>
                                    {getFieldDecorator('startDate', {
                                        initialValue: params&&params.startDate ? moment(params.startDate, "YYYY-MM-DD") : moment(),
                                        rules: [{ required:false, message: '请选择开始日期' }],
                                    })(
                                        <DatePicker style={{ width: '100%' }} placeholder={'开始日期'} disabledDate={(curDate) => {
                                        return curDate && curDate > moment().endOf('day');
                                        }} />
                                    )}
                                    </FormItem>
                                </Col>
                                <Col span={6} >
                                <FormItem label='失效日期' {...formItemLayout}>
                                    {getFieldDecorator('stopDate', {
                                    initialValue: params&&params.stopDate ? moment(params.stopDate, "YYYY-MM-DD") : undefined,
                                    rules: [{ required: false, message: '' }],
                                    })(
                                    <DatePicker style={{ width: '100%' }} placeholder={'请选择失效日期'} disabledDate={(curDate) => {
                                        return curDate < moment(this.props.form.getFieldValue('stopDate')).format('YYYY-MM-DD');
                                    }} />
                                    )}
                                </FormItem>
                                </Col >
                            </Row>
                            <Row gutter={60}>
                                <Col span={6} className="patNameDom">
                                        <FormItem {...formItemLayout} label='授权码'>
                                            {getFieldDecorator('authorizeCode', {
                                                initialValue: params&&params.authorizeCode ?  params&&params.authorizeCode : undefined,
                                                rules: [{ required: false, message: '', },
                                                ],
                                            })(
                                                <Input/>
                                            )}
                                        </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='医院介绍'>
                                        {getFieldDecorator('introduce', {
                                            initialValue: params&&params.introduce ?  params&&params.introduce : undefined,
                                            rules: [{ required: false, message: '', }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='医院LOGO'>
                                        {getFieldDecorator('logo', {
                                           initialValue: params&&params.logo ?  params&&params.logo : undefined,
                                            rules: [{ required: false, message: '', },]
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayoutNumber} label='每行显示床数'>
                                        {getFieldDecorator('oneRowNumber', {
                                            initialValue: params&&params.oneRowNumber ?  params&&params.oneRowNumber : undefined,
                                            rules: [{ required: false, message: '', }]
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row gutter={60}>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='床位图高'>
                                        {getFieldDecorator('height', {
                                           initialValue: params&&params.height ?  params&&params.height : undefined,
                                            rules: [{ required: false, message: '', }],
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='床位图宽'>
                                        {getFieldDecorator('width', {
                                          initialValue: params&&params.hospSeqNo ?  params&&params.hospSeqNo : undefined,
                                            rules: [{ required: false, message: '', },]
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={6}>
                                    <FormItem {...formItemLayout} label='床位间隔'>
                                        {getFieldDecorator('bedInterval', {
                                           initialValue: params&&params.bedInterval ?  params&&params.bedInterval : undefined,
                                            rules: [{ required: false, message: '', }]
                                        })(
                                            <Input/>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row>
                            <Col span={18} style={{display:"flex",justifyContent: "space-around",marginTop:"16px"}} >
                                        <Button   type="primary" onClick={this.save}>{this.state.rowId&&this.state.rowId?"更新":"新增"}</Button>
                                        <Popconfirm title="是否要删除此行" onConfirm={this.delete}>
                                        <Button type="danger" disabled={this.state.rowId&&this.state.rowId?false:true} >删除</Button>
                                         </Popconfirm>
                                        <Button   type="primary" onClick={this.reset}>重置</Button>
                                </Col >
                            </Row>
                        </Form>                                    
                            </Card>
                        </div>
                    </Col>
                </Row>
                {/* 新增配置 */}
                <CBDataImport className={"User.CBHospital"} ClassTitle={"导数据"} ref={(dataImport)=>this.DataImport=dataImport} />
            </div>
        );
    }
})
export default HospitalMaintenance;
